// StudentService.java
public class StudentService {
    private StudentDAO studentDAO = new StudentDAO();

    public void registerStudent(String id, String name, String major, String classGroup) {
        Student student = new Student(id, name, major, classGroup);
        studentDAO.addStudent(student);
    }

    public Student findStudentById(String id) {
        return studentDAO.getStudentById(id);
    }

    public void removeStudent(String id) {
        studentDAO.deleteStudentById(id);
    }

    public void printAllStudents() {
        for (Student student : studentDAO.getAllStudents()) {
            System.out.println(student);
        }
    }

    public static void main(String[] args) {
        StudentService studentService = new StudentService();

        // 添加学生
        studentService.registerStudent("1", "21-计科本8-张文骏", "计算机科学", "21-计科本8");

        // 打印所有学生
        studentService.printAllStudents();

        // 查找学生
        Student student = studentService.findStudentById("1");
        if (student != null) {
            System.out.println("找到学生: " + student);
        }

        // 删除学生
        studentService.removeStudent("1");

        // 再次打印所有学生
        studentService.printAllStudents();
    }
}